/*
 *  $Id: GraveFlowers.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using System;

namespace Ragima.Cards001.Light.Spells {
    public class GraveFlowers: TargetEnchantmentCard<Creature> {
        public GraveFlowers(): base("001_l_s_grave_flowers") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Light;
            Value = 100;
            Target = CreatureTarget.Both;
            AddManaCost(ElementType.Light, 1);
            AddManaCost(ElementType.Earth, 1);
        }

        protected override bool IsPossibleAction(TargetArgs<Creature> args) {
            int mana = 1 + Math.Max(args.Target.Card.GetSumMana()-2, 0);
            bool enough = args.Player.GetMana(ElementType.Light) >= mana;
            if (!enough) args.Player.Game.ErrorNotice(ManaCondition.NotEnough.GetText(ElementType.Light));
            return enough;
        }

        protected override void DoAction(TargetArgs<Creature> args) {
            int mana = Math.Max(args.Target.Card.GetSumMana()-2, 0);
            if (mana > 0) args.Player.DecrementMana(ElementType.Light, mana);
            base.DoAction(args);
        }
        protected override EnchantmentAffect CreateEnchantment() {
            return new GraveFlowersAffect();
        }

        private class GraveFlowersAffect: GraveyardEnchantmentAffect<GraveFlowers> {
            public GraveFlowersAffect() {
                Add(new Affects.GraveyardAntimagic());
            }
        }
    }
}
